package chinlone.pedometer;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.util.Log;

public class httpPost {

	public httpPost() {
		// TODO Auto-generated constructor stub
	}

	
	

public String postUrl(String url){ 
HttpClient httpclient = new DefaultHttpClient(); 
//你的URL
  HttpPost httppost = new HttpPost(url); 
  HttpResponse response; 
  String retPost = "no no no!";
  try { 
   List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); 
//Your DATA 
   nameValuePairs.add(new BasicNameValuePair("name", "test")); 
   nameValuePairs.add(new BasicNameValuePair("original_lat", "30.53885")); 
   nameValuePairs.add(new BasicNameValuePair("original_lon", "104.055444"));
   nameValuePairs.add(new BasicNameValuePair("original_coord_type", "2"));
   nameValuePairs.add(new BasicNameValuePair("databox_id", "3022"));
   nameValuePairs.add(new BasicNameValuePair("ak", "6cbcdcbae22e954118a6729d1c349258"));

   httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 

   response=httpclient.execute(httppost); 
  InputStream ins = response.getEntity().getContent();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  int i = -1;
  while((i = ins.read()) != -1){
	  baos.write(i);
  }
  retPost =  baos.toString();
  

  } catch (ClientProtocolException e) { 
   // TODO Auto-generated catch block 
   e.printStackTrace(); 
   
  } catch (IOException e) { 
   // TODO Auto-generated catch block 
   e.printStackTrace(); 
  }
return retPost; 

}
	
	
	

}
